// eslint-disable-next-line max-classes-per-file
import { JsonProperty, Serializable } from '@/plugins/reflect-metadata';

@Serializable()
export class LoginRes {
  @JsonProperty('code')
    code: number = 0;

  @JsonProperty('msg')
    msg: string = '';

  @JsonProperty('token')
    token: string = '';
}

@Serializable()
export default class LoginInstance {
  @JsonProperty('phone')
    phone: string = '';

  @JsonProperty('password')
    password: string = '';

  @JsonProperty('captchaVerification')
    captchaVerification: string = '';

  get loginByPassword() {
    return {
      phone: this.phone,
      password: this.password,
      userType: '03',
    };
  }

  get loginByCode() {
    return {
      phone: this.phone,
      code: this.code,
      captchaVerification: this.captchaVerification,
    };
  }

  @JsonProperty('nickName')
    nickName: string = '';

  @JsonProperty('phoneNumber')
    phoneNumber: string = '';

  @JsonProperty('code')
    code: string = '';

  get registerBody() {
    return {
      nickName: this.nickName,
      phoneNumber: this.phoneNumber,
      code: this.code,
      password: this.password,
      userType: '03',
    };
  }

  get phoneCode() {
    return {
      phone: this.phone || this.phoneNumber,
      captchaVerification: this.captchaVerification,
    };
  }
}
